package com.zhl.common.exception;

import com.zhl.common.enums.SystemEnums;
import com.zhl.common.enums.IEnum;

/**
 * @Author: z156940l@outlook.com
 * @Date: 2021/8/3 11:07
 */
public abstract class BaseException extends RuntimeException implements ExceptionScalable {
    private static final long serialVersionUID = 5692243177785821696L;

    private IEnum error;
    private Object data = "";

    public BaseException() {}

    public BaseException(String msg){
        this.error = SystemEnums.FAIL;
        this.error.setMsg(msg);
    }

    public BaseException(IEnum error) {
        this.error = error;
    }

    public BaseException(IEnum error, Object data) {
        this.error = error;
        this.data = data;
    }

    public BaseException(IEnum error, String msg, Object data) {
        this.error = error;
        this.error.setMsg(msg);
        this.data = data;
    }

    public BaseException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }

    @Override
    public IEnum getError() {
        return error;
    }

    @Override
    public Object getData() {
        return data;
    }
}
